<?php

namespace App\Http\Controllers\Agency;
use App\Http\Controllers\Controller;
use App\Services\WallService;
use Illuminate\Http\Request;
use hg\apidoc\annotation as Apidoc;
/**
 * 脱单墙
 * @Apidoc\Group("market")
 */
class WallController extends Controller
{
    /**
     * @Apidoc\Title ("脱单墙-案例列表")
     * @Apidoc\Url("/agency/getWallList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=true,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=true,desc="每页条数")
     * @Apidoc\Param("title",type="string",require=false,desc="案例名称")
     * @Apidoc\Returned("id",type="int",require=false,desc="id")
     * @Apidoc\Returned("title",type="string",desc="标题")
     * @Apidoc\Returned("cover",type="string",desc="封面图")
     * @Apidoc\Returned("status",type="string",desc="状态1恋爱了2订婚了3结婚了")
     * @Apidoc\Returned("content",type="string",desc="内容")
     * @Apidoc\Returned("order",type="string",desc="排序")
     * @Apidoc\Returned("malename",type="int",desc="男方")
     * @Apidoc\Returned("femalename",type="int",desc="女方")
     * @Apidoc\Returned("zans",type="int",desc="祝福数")
     * @Apidoc\Returned("views",type="int",desc="浏览量")
     * @Apidoc\Returned("created_at",type="object",desc="发布时间")
     */
    public function getWallList(Request $request ,WallService $wallService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $wallService->getWallList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("搭子管理-保存案例")
     * @Apidoc\Url("/agency/wallUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=false,desc="新增时传空，修改时传列表id")
     * @Apidoc\Param("title",type="string",require=true,desc="标题")
     * @Apidoc\Param("cover",type="string",require=true,desc="封面图")
     * @Apidoc\Param("status",type="int",require=true,desc="状态1恋爱了2订婚了3结婚了")
     * @Apidoc\Param("content",type="string",require=true,desc="内容")
     * @Apidoc\Param("order",type="int",require=true,desc="排序")
     * @Apidoc\Param("malename",type="int",require=false,desc="男方")
     * @Apidoc\Param("femalename",type="int",require=false,desc="女方")
     * @Apidoc\Param("zans",type="int",require=false,desc="祝福数")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function wallUpdate(Request $request ,WallService $wallService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $wallService->wallUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("搭子管理-删除案例")
     * @Apidoc\Url("/agency/wallDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=false,desc="列表id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function wallDel(Request $request ,WallService $wallService)
    {
        $params = $request->input();
        $result = $wallService->wallDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }
}
